use yew::prelude::*;

#[derive(Clone, PartialEq)]
pub enum LaunchButtonState {
    Stopped,
    Running,
    Loading,
}

#[derive(Properties, Clone, PartialEq)]
pub struct LaunchButtonProps {
    pub state: LaunchButtonState,
    pub onclick: Callback<()>,
}

#[function_component]
pub fn LaunchButton(props: &LaunchButtonProps) -> Html {
    let text = match props.state {
        LaunchButtonState::Stopped => "启动",
        LaunchButtonState::Running => "停止",
        LaunchButtonState::Loading => "刷新",
    };
    // let loading = props.state == LaunchButtonState::Loading;
    let onclick = props.onclick.reform(|_| ());
    html! {
        <button class="launch-button" {onclick}>{text}</button>
    }
}